package com.threegold.listview;

import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.app.Context;

public abstract class LoadMoreView {

    protected final Component layoutView;

    public LoadMoreView(Context context, ComponentContainer parent) {
        layoutView = initLoadMoreLayout(context, parent);
        if (layoutView == null) {
            throw new RuntimeException("initLoadMoreLayout can not be null");
        }
    }

    public Component getLayoutView() {
        return layoutView;
    }

    void onCanLoadMoreChanged(boolean hasMore) {
        if (hasMore) {
            showLoadingLayout();
        } else {
            showNoMoreLayout();
        }
    }

    protected abstract void showNoMoreLayout();

    protected abstract void showLoadingLayout();

    protected abstract Component initLoadMoreLayout(Context context, ComponentContainer parent);
}
